<?php

namespace app\api\controller;

use app\common\controller\Api;

class Label extends Api
{
    protected $noNeedRight = ['*'];

    public function add()
    {
        $name = input('name','');
        $model = new \app\admin\model\Label();
        $data = [
            'user_id'=>$this->auth->id,
            'name'=>$name,
            'weigh'=>0
        ];
        $res = $model->save($data);

        $this->success('');
    }

    public function del()
    {
        $id = input('id',0);

        $detail = \app\admin\model\Label::get($id);
        $detail->delete();

        $this->success('删除成功');
    }


    public function lists()
    {
        $list = \app\admin\model\Label::all();
        $this->success('成功',$list);
    }
}